<?php

class TransactionCentral_ACH_Transaction extends TransactionCentral_Transaction
{
    protected $ref_id              = '';
    protected $amount              = '';
    protected $trans_route         = '';
    protected $bank_account_no     = '';    
    protected $name                = '';
    protected $bank_account_type   = '';
    protected $check_type          = '';
    protected $description         = '';
    
    /*
     * Optional Fields
     */
    protected $address         = '';
    protected $zip_code        = '';
    protected $process_date    = '';
    
    public function process($credit_or_debit)
    {
        if($credit_or_debit == 'Credit') {
            $ach_credit = new TransactionCentral_ACH_Transaction_Credit($this);
            return $ach_credit->process();
        } elseif ($credit_or_debit == 'Debit') {
            $ach_debit = new TransactionCentral_ACH_Transaction_Debit($this);
            return $ach_debit->process();
        } else {
            throw new Exception(get_class($this) . '::' . __FUNCTION__ . ' must be passed either "Credit" or "Debit"');
        }
    }
    
    public function getStatus()
	{
	    //TODO: Implement
	}
	
	public function verify()
	{
	    //TODO: Implement
	}
	
	public function void()
	{
	    //TODO: Implement
	}  
    
    /*
     * Start Getters/Setters
     */
    
    /**
     * Get the Ref ID for this Transaction. 
     * 
     * @return	The Ref ID for this Transaction.
     */
    public function getRefId ()
    {
        return $this->ref_id;
    }

	/**
	 * Set the Ref ID for this object.
	 * Required.
	 * 
     * @param	The reference ID for this Transaction.
     * @return	This object.
     */
    public function setRefId ($ref_id)
    {
        $this->ref_id = $ref_id;
        return $this;
    }

	/**
	 * Get the amount for this Transaction.
	 * 
     * @return	The amount for this Transaction.
     */
    public function getAmount ()
    {
        return $this->amount;
    }

	/**
	 * Set the amount for this Transaction.
	 * Required.
	 * 
     * @param	The amount for this Transaction.
     * @return	This object.
     */
    public function setAmount ($amount)
    {
        $this->amount = $amount;
        return $this;
    }

	/**
	 * Get the routing number for this Transaction (if set).
	 * 
     * @return	The routing number for this Transaction.
     */
    public function getTransRoute ()
    {
        return $this->trans_route;
    }

	/**
	 * Set the routing number for this Transaction.
	 * Required.
	 * 
     * @param	The routing number for this Transaction.
     * @retun 	This object.
     */
    public function setTransRoute ($trans_route)
    {
        $this->trans_route = $trans_route;
        return $this;
    }

	/**
	 * Get the bank account number for the Transaction (if set).
	 * 
     * @return	The bank account number for the Transaction.
     */
    public function getBankAccountNo ()
    {
        return $this->bank_account_no;
    }

	/**
	 * Set the bank account number for the Transaction.
	 * Required.
	 * 
     * @param	The bank account number for the Transaction.
     * @return	This object.
     */
    public function setBankAccountNo ($bank_account_no)
    {
        $this->bank_account_no = $bank_account_no;
        return $this;
    }

	/**
	 * Get the name of the person on the account that the Transaction will be posted to (if set).
	 * 
     * @return	The name of the person on the account that the Transaction will be posted to.
     */
    public function getName ()
    {
        return $this->name;
    }

	/**
	 * Set the name of the person on the account that the Transaction will be posted to.
	 * Required.
	 * 
     * @param	Name of person on the account the Transaction will be posted to.
     * @return	This object.
     */
    public function setName ($name)
    {
        $this->name = $name;
        return $this;
    }

	/**
	 * Get the banks account type, will be "Checking" or "Saving" (if set).
	 * 
     * @return	The bank account type, will be either "Checking" or "Saving" (if set).
     */
    public function getBankAccountType ()
    {
        return $this->bank_account_type;
    }

	/**
	 * Set the account type for the Transaction to post to, must be "Checking" or "Saving"
	 * Required.
	 * 
     * @param	The bank account type for the Transaction, must be either "Checking" or "Saving"
     */
    public function setBankAccountType ($bank_account_type)
    {
        if ($bank_account_type != 'Checking' && $bank_account_type != 'Saving') {
        	throw new Exception("Bank account type must be either Checking or Saving");
        }
       
        $this->bank_account_type = $bank_account_type;
        return $this;
    }

	/**
	 * Gets check type, a.k.a. if the Transaction will be posting to a 'Personal' or 'Business' account.
	 * 
     * @return	The 'check type,' a.k.a. if the Transaction is going to be posted to a "Personal" or "Business" account (if set).
     */
    public function getCheckType ()
    {
        return $this->check_type;
    }

	/**
	 * Sets the type of account that the Transaction will be posted against, must be either 'Personal' or 'Business'
	 * Required.
	 * 
     * @param	The 'check type' for the Transaction. Basically what kind of account the Transaction is coming 
     * 			from, the allowed options are 'Personal' and 'Business'
     * @return	This object.
     */
    public function setCheckType ($check_type)
    {
        if ($check_type != 'Personal' && $check_type != 'Business') {
        	throw new Exception('Check type must be either \'Personal\' or \'Business\'');
        }
        
        $this->check_type = $check_type;
        return $this;
    }

	/**
	 * Get the address fo the account that the Transaction will be posted to (if set).
	 * 
     * @return	The address of the bank account the Transaction will be posted to.
     */
    public function getAddress ()
    {
        return $this->address;
    }

	/**
	 * Set the address of the bank account that this Transaction wil lbe posted to.
	 * 
     * @param	Set the address of the bank account that the Transaction is to be posted to.
     * @return	This object.
     */
    public function setAddress ($address)
    {
        $this->address = $address;
        return $this;
    }

	/**
	 * Get zip code of the bank account that the Transaction will be posted to (if set).
	 * 
     * @return	The zip code of the bank account that the Transaction will be posted to.
     */
    public function getZipCode ()
    {
        return $this->zip_code;
    }

	/**
	 * Sets the zip code of the bank account that the Transaction will be posted to.
	 * 
     * @param	The zip code for the account being credited/debited.
     * @return	This object.
     */
    public function setZipCode ($zip_code)
    {
        $this->zip_code = $zip_code;
        return $this;
    }

	/**
	 * Gets the current date the the Transaction will be set to process (if set).
	 * 
     * @return	The date for the current Transaction to be processed.
     */
    public function getProcessDate ()
    {
        return $this->process_date;
    }

	/**
	 * Sets the date the transation is to be processed (if set).
	 * 
     * @param	Date to process the Transaction.
     * @return	This object.
     */
    public function setProcessDate ($process_date)
    {
        $this->process_date = $process_date;
        return $this;
    }

	/**
	 * Return the current description (name that appears on the bank statement) of the Transaction (if set).
	 * Required.
	 * 
     * @return	The description for the Transaction.
     */
    public function getDescription ()
    {
        return $this->description;
    }

	/**
	 * Function used to set the description of the Transaction, a.k.a., the name that shows
	 * up on the bank statement.
	 * 
     * @param	The description.
     * @return	This object
     */
    public function setDescription ($description)
    {
        $this->description = $description;
        return $this;
    }
}